//请求的主地址
window.mainhost = 'http://app-tui.ngzb.com.cn'

const {
    Header,
    HomePage,
    InfoPage,
    ResultPage,
    SelfPage,
    BottomNav,
    LoginPage
} = require('./view.js')

const {
    loginStore,
    homeStore,
    resultStore,
    selfStore,
    infoStore,
} = require('./store/dataStore.js')

//首页
const Home = Vue.extend({
    components: {
        Header,
        HomePage,
        BottomNav
    },
    template: `
        <div>
            <Header></Header>
            <HomePage></HomePage>
            <BottomNav activeItem=1></BottomNav>
        </div>
    `,
    router,
    store: homeStore
})

//信息
const Info = Vue.extend({
    components: {
        Header,
        InfoPage,
        BottomNav
    },
    template: `
        <div>
            <Header></Header>
            <InfoPage></InfoPage>
            <BottomNav activeItem=2></BottomNav>
        </div>
    `,
    router,
    store: infoStore
})

//结果
const Result = Vue.extend({
    components: {
        Header,
        ResultPage,
        BottomNav
    },
    template: `
        <div>
            <Header textTitle="推广效果"></Header>
            <ResultPage></ResultPage>
            <BottomNav activeItem=3></BottomNav>
        </div>
    `,
    router,
    store: resultStore
})

//个人
const Self = Vue.extend({
    components: {
        Header,
        SelfPage,
        BottomNav
    },
    template: `
        <div>
            <Header textTitle="个人中心"></Header>
            <SelfPage></SelfPage>
            <BottomNav activeItem=4></BottomNav>
        </div>
    `,
    router,
    store: selfStore
})

//登录
const Login = Vue.extend({
    components: {
        LoginPage
    },
    template: `
        <LoginPage></LoginPage>
    `,
    router,
    store: loginStore
})


//页面路由
Vue.use(VueRouter)
const routes = [{
        path: '/Home',
        component: Home
    },
    {
        path: '/info',
        component: Info
    },
    {
        path: '/result',
        component: Result
    },
    {
        path: '/self',
        component: Self
    },
    {
        path: '/',
        component: Login
    },
]
const router = new VueRouter({
    routes,
    scrollBehavior(to, from, savePosition) {
        return {
            x: 0,
            y: 0
        }
    }
})
window.app = new Vue({
    router
}).$mount('#app')